from pydantic import BaseModel, Field
from typing import List, Dict, Optional


class _StepModel(BaseModel):
    desc: str = Field(..., description="步骤描述")

    # method 和 keyword 二选一
    method: str = Field(default=None, description="要调用的方法名")
    keyword: str = Field(default=None, description="要执行的关键词")

    # params 默认空字典
    params: Dict = Field(default_factory=dict, description="方法参数")


class _CaseModel(BaseModel):
    id: str = Field(..., description="用例ID")
    name: str = Field(..., description="用例名称")
    skip: bool = Field(False, description="是否跳过")
    steps: List[_StepModel] = Field(default_factory=list, description="测试步骤列表")


class SuiteModel(BaseModel):
    id: str = Field(..., description="套件ID")
    name: str = Field(..., description="套件名称")
    setup_step: List[_StepModel | dict] = Field(default_factory=list, description="前置步骤")
    cases: List[_CaseModel | dict] = Field(default_factory=list, description="测试用例列表")


class ConfigModel(BaseModel):
    # 是否调试模式: 默认True, 控制是否启用无头模式，True为关闭，False为开启
    is_debug: bool = Field(True, description="是否调试模式")

    # 浏览器类型: 默认"chromium"
    browser_type: str = Field("chromium", description="浏览器类型")

    # 远程调试配置: "127.0.0.1:9222"
    host: str = Field(..., description="远程调试地址")

    # 全局变量: 默认空字典
    global_variable: Dict = Field(default_factory=dict, description="全局变量")
